package com.hyz.controller;

import com.hyz.pojo.request.ApplicantAsRequest;
import com.hyz.pojo.response.*;
import com.hyz.service.ApplicantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import pojo.ResponseResult;
import pojo.asset.asset.AssetClasses;

import java.util.List;
import java.util.Map;


/**
 * @author HGD
 * @date 2022/10/8 20:16
 */
@Api("申请人员")
@RestController
@RequestMapping("/applicant")
public class ApplicantController {
    @Autowired
    private ApplicantService service;

    //------------------------------------------------------------------------------------------------
    // 资产借调

    @ApiOperation("资产借调人员获取所有的可借资产和申请种类")
    @PostMapping("/getAllowBorrowAssets")
    public ResponseResult<GetAllowBorrowAssetsResponse> getAllowBorrowAssets() {
        return service.getAllowBorrowAssets();
    }


    @ApiOperation("资产借调人员获取借调记录")
    @PostMapping("/getAssetSecondments")
    public ResponseResult<List<AssetSecondmentResponse>> getAssetSecondments() {
        return service.getAssetSecondments();
    }

    @ApiOperation("借调人员创建借调申请")
    @PostMapping("/insertAssetSecondment")
    public ResponseResult<List<AssetSecondmentResponse>> insertAssetSecondment(@RequestBody ApplicantAsRequest request) {
        return service.insertAssetSecondment(request);
    }


    @ApiOperation("申请人根据资产种类获取资产列表")
    @GetMapping("/getAllowBorrowAssetsByClasses/{classes}")
    public ResponseResult<Map<String, List<GetAllowBorrowAssetsByClassesResponse>>> getAllowBorrowAssetsByClasses(@PathVariable("classes") String classes) {
        AssetClasses assetClasses = null;
        if("HARDWARE_ASSET".equals(classes)){
            assetClasses = AssetClasses.HARDWARE_ASSET;
        } else if ("SOFTWARE_ASSET".equals(classes)) {
            assetClasses = AssetClasses.SOFTWARE_ASSET;
        } else if ("VIRTUAL_ASSET".equals(classes)){
            assetClasses = AssetClasses.VIRTUAL_ASSET;
        }
        return service.getAllowBorrowAssetsByClasses(assetClasses);
    }

    //------------------------------------------------------------------------------------------------
    // 资产维修

    @ApiOperation("申请人查询维修申请")
    @PostMapping("/apGetAssetMaintenance")
    public ResponseResult<List<AssetMaintenanceResponse>> apGetAssetMaintenance() {
        return service.apGetAssetMaintenance();
    }

    @ApiOperation("申请人创建维修申请")
    @PostMapping("/insertAssetMaintenance")
    public ResponseResult<List<AssetMaintenanceResponse>> insertAssetMaintenance(@RequestBody Long assetId) {
        return service.insertAssetMaintenance(assetId);
    }

    //------------------------------------------------------------------------------------------------
    // 资产报废

    @ApiOperation("申请人获取资产报废申请")
    @PostMapping("/apGetAssetRetirement")
    public ResponseResult<List<AssetRetirementResponse>> apGetAssetRetirement() {
        return service.apGetAssetRetirement();
    }

    @ApiOperation("申请人创建报废申请")
    @PostMapping("/insertAssetRetirement")
    public ResponseResult<List<AssetRetirementResponse>> insertAssetRetirement(@RequestBody Long assetId) {
        return service.insertAssetRetirement(assetId);
    }

    //------------------------------------------------------------------------------------------------
    // 资产盘点



}
